package com.distribute.framework.model;

import com.distribute.framework.core.web.helper.Utils;
import java.lang.reflect.Field;
import java.util.Date; 
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;

import javax.annotation.Resource;

import com.distribute.framework.core.web.util.Page;
import com.distribute.framework.core.lang.*; 
import com.distribute.framework.core.web.helper.WebHelper.LzMap;
import com.distribute.framework.core.util.Function;
import com.distribute.framework.core.util.IbatisMap;
import com.distribute.framework.config.*;
import com.distribute.framework.plugin.*;

@namespace("users/invitrecord")
public @caption("邀请记录") @database(DatabaseNames.distribute_sys) @source("distribute_sys") @table("invit_record") class InvitRecord implements java.io.Serializable
{
	private static final long serialVersionUID = 1l;
		
	
		
	private @caption("编号") @column("id")    @primary  @notnull  @note("  ") Long id;// 主键 非空     
			
 			
 			
 		
	
		
	private @caption("品牌") @column("brand")      @relate("$brand") @RelateClass(Merchant.class)  @note("  ") Long brand;//     
			
 	private transient Merchant $brand;//关联对象[品牌信息]
 			
 			
 			
 		
	
		
	private @caption("被邀人") @column("invited_person")     @notnull  @relate("$invitedPerson") @RelateClass(Member.class)  @note("  ") Long invitedPerson;// 非空     
			
 	private transient Member $invitedPerson;//关联对象[会员信息]
 			
 			
 			
 		
	
		
	private @caption("折扣券ID") @column("invited_coupon")      @relate("$invitedCoupon") @RelateClass(Coupon.class)  @note("  ") Long invitedCoupon;//     
			
 	private transient Coupon $invitedCoupon;//关联对象[用户优惠券]
 			
 			
 			
 		
	
		
	private @caption("受邀折扣") @column("invited_discount")      @note("  ") Double invitedDiscount;//     
			
 			
 			
 		
	
		
	private @caption("推荐人") @column("recom")     @notnull  @relate("$recom") @RelateClass(Member.class)  @note("  ") Long recom;// 非空     
			
 	private transient Member $recom;//关联对象[会员信息]
 			
 			
 			
 		
	
		
	private @caption("折扣券ID") @column("recom_coupon")      @relate("$recomCoupon") @RelateClass(Coupon.class)  @note("  ") Long recomCoupon;//     
			
 	private transient Coupon $recomCoupon;//关联对象[用户优惠券]
 			
 			
 			
 		
	
		
	private @caption("折扣") @column("recom_discount")      @note("  ") Double recomDiscount;//     
			
 			
 			
 		
	
		
	private @caption("邀请类型") @column("invitr_type")      @note(" 1:新人邀请 2:老用户回归  ") Short invitrType;// 1:新人邀请 2:老用户回归     
			
 			
 			
 		
	
		
	private @caption("修改时间") @column("update_time")     @notnull  @note("  ") Date updateTime;// 非空     
			
 			
 			
 		
	
		
	private @caption("添加时间") @column("add_time")     @notnull  @note("  ") Date addTime;// 非空     
			
 			
 			
 		
	
		
	private @caption("状态") @column("status")     @notnull  @note(" 1:正常 0:无效  ") Short status;// 非空 1:正常 0:无效     
			
 			
 			
 		
	
	 
	//默认构造函数
	public InvitRecord(){ 
	
	}
	
	//主键构造函数
	public InvitRecord(Long id){
		this.id = id;
	}
	
	/**所有字段构造函数 
	 InvitRecord(
	 	Utils.getLong("")//品牌
	 	,Utils.getLong("person")//被邀人 [非空]
	 	,Utils.getLong("coupon")//折扣券ID
	 	,Utils.getDouble("discount")//受邀折扣
	 	,Utils.getLong("")//推荐人 [非空]
	 	,Utils.getLong("coupon")//折扣券ID
	 	,Utils.getDouble("discount")//折扣
	 	,Utils.getShort("type")//邀请类型
	 	,Utils.getDate("time")//修改时间 [非空]
	 	,Utils.getDate("time")//添加时间 [非空]
	 	,Utils.getShort("")//状态 [非空]
	 )
	**/
	public InvitRecord(Long brand,Long invitedPerson,Long invitedCoupon,Double invitedDiscount,Long recom,Long recomCoupon,Double recomDiscount,Short invitrType,Date updateTime,Date addTime,Short status){
		
			
			
		this.brand=brand;
		
			
		this.invitedPerson=invitedPerson;
		
			
		this.invitedCoupon=invitedCoupon;
		
			
		this.invitedDiscount=invitedDiscount;
		
			
		this.recom=recom;
		
			
		this.recomCoupon=recomCoupon;
		
			
		this.recomDiscount=recomDiscount;
		
			
		this.invitrType=invitrType;
		
			
		this.updateTime=updateTime;
		
			
		this.addTime=addTime;
		
			
		this.status=status;
		
	}
	
	//设置非空字段
	public InvitRecord setNotNull(Long invitedPerson,Long recom,Date updateTime,Date addTime,Short status){
		
			
			
			
		this.invitedPerson=invitedPerson;
		
			
			
			
		this.recom=recom;
		
			
			
			
			
		this.updateTime=updateTime;
		
			
		this.addTime=addTime;
		
			
		this.status=status;
		
		return this;
	}
	
	
		
	/** 编号 [非空]       **/
	public InvitRecord id(Long id){
		this.id = id;
		this.setSeted(F.id);
		return this;
	}
	
		
	/** 品牌  [Merchant]      **/
	public InvitRecord brand(Long brand){
		this.brand = brand;
		this.setSeted(F.brand);
		return this;
	}
	
		
	/** 被邀人 [非空] [Member]      **/
	public InvitRecord invitedPerson(Long invitedPerson){
		this.invitedPerson = invitedPerson;
		this.setSeted(F.invitedPerson);
		return this;
	}
	
		
	/** 折扣券ID  [Coupon]      **/
	public InvitRecord invitedCoupon(Long invitedCoupon){
		this.invitedCoupon = invitedCoupon;
		this.setSeted(F.invitedCoupon);
		return this;
	}
	
		
	/** 受邀折扣        **/
	public InvitRecord invitedDiscount(Double invitedDiscount){
		this.invitedDiscount = invitedDiscount;
		this.setSeted(F.invitedDiscount);
		return this;
	}
	
		
	/** 推荐人 [非空] [Member]      **/
	public InvitRecord recom(Long recom){
		this.recom = recom;
		this.setSeted(F.recom);
		return this;
	}
	
		
	/** 折扣券ID  [Coupon]      **/
	public InvitRecord recomCoupon(Long recomCoupon){
		this.recomCoupon = recomCoupon;
		this.setSeted(F.recomCoupon);
		return this;
	}
	
		
	/** 折扣        **/
	public InvitRecord recomDiscount(Double recomDiscount){
		this.recomDiscount = recomDiscount;
		this.setSeted(F.recomDiscount);
		return this;
	}
	
		
	/** 邀请类型    1:新人邀请 2:老用户回归     **/
	public InvitRecord invitrType(Short invitrType){
		this.invitrType = invitrType;
		this.setSeted(F.invitrType);
		return this;
	}
	
		
	/** 修改时间 [非空]       **/
	public InvitRecord updateTime(Date updateTime){
		this.updateTime = updateTime;
		this.setSeted(F.updateTime);
		return this;
	}
	
		
	/** 添加时间 [非空]       **/
	public InvitRecord addTime(Date addTime){
		this.addTime = addTime;
		this.setSeted(F.addTime);
		return this;
	}
	
		
	/** 状态 [非空]   1:正常 0:无效     **/
	public InvitRecord status(Short status){
		this.status = status;
		this.setSeted(F.status);
		return this;
	}
	
	
	
	/**
	* 克隆对象
	**/
	public InvitRecord clone(){
		InvitRecord clone = new InvitRecord();
		
			
			
		clone.brand=this.brand;
		
			
		clone.invitedPerson=this.invitedPerson;
		
			
		clone.invitedCoupon=this.invitedCoupon;
		
			
		clone.invitedDiscount=this.invitedDiscount;
		
			
		clone.recom=this.recom;
		
			
		clone.recomCoupon=this.recomCoupon;
		
			
		clone.recomDiscount=this.recomDiscount;
		
			
		clone.invitrType=this.invitrType;
		
			
		clone.updateTime=this.updateTime;
		
			
		clone.addTime=this.addTime;
		
			
		clone.status=this.status;
		
		return clone;
	}
	
	
	
	
	
	/**
	 * 根据ID取邀请记录
	 * @param id
	 * @return
	 */
	public static @api InvitRecord get(Long id){		
		return getInvitRecordById(id);
	}
	
	
	
	/**
	 * 获取所有邀请记录
	 * @return
	 */
	public static @api List<InvitRecord> list(Map params,Integer size){
		return getInvitRecordList(params,size);
	}
	/**
	 * 获取邀请记录分页
	 * @return
	 */
	public static @api Page<InvitRecord> page(Integer page,Integer size,Map params){
		return getInvitRecordPage(page, size , params);
	}
	
	
	/**
	 * 根据查询条件取邀请记录
	 * @param params
	 * @return
	 */
	public static @api InvitRecord Get(Map params){
		return getInvitRecord(params);
	}
	/**
	 * 获取邀请记录数
	 * @return
	 */
	public static @api Long count(Map params){
		return getInvitRecordCount(params);
	}
	/**
	 * 获取邀请记录数
	 * @return
	 */
	public static @api <T> T eval(String eval,Map params){
		return getInvitRecordEval(eval,params);
	}
	
	
	/**
	 * 获取邀请记录图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey){
		return getInvitRecordStats(params,sumKey,groupKey,-1);
	}
	/**
	 * 获取邀请记录图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey,int dateType){
		return getInvitRecordStats(params,sumKey,groupKey,dateType);
	}
	
	
	/**
	 * 根据ID取邀请记录
	 * @param id
	 * @return
	 */
	public static @api InvitRecord getInvitRecordById(Long id){		
		return getInvitRecordDao().getInvitRecordById(id);
	}
	
	
	
	
	/**
	 * 根据ID取邀请记录的标识键值
	 * @param id
	 * @return
	 */
	public static @api String getKeyValue(Object key){
		Long id = Utils.parseLong(key);	
		if(id==null || id.longValue()==0 ){
			
			return null;
			
		}
		String value = null;
				
		if(value==null){
			InvitRecord invitRecord = get(id);
			if(invitRecord!=null){
				String strValue = invitRecord.getId$();
				
				
				value = strValue;
			}else{
				
				value = "{"+id+"}";
			}
		}
		
		/************LAZY3Q_ID_KEYVALUE************/
		/************LAZY3Q_ID_KEYVALUE************/
		return value;
	}	
	
	
	/**
	 * 获取当前对象的键值
	 * @return
	 */
	public String getKeyValue(){
		
		/************LAZY3Q_CODE_KEYVALUE************/
		/************LAZY3Q_CODE_KEYVALUE************/
		String keyValue = this.getId$();
		
		return keyValue;
	}
	
	
	/**
	 * 根据关键字精确查询邀请记录对象
	 * @return
	 */
	public static @api InvitRecord find(String key){
		if(Utils.empty(key))return null;
		Map params = new HashMap();
		if(key.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
			params.put("id", key.toLowerCase().replaceFirst("id:", ""));					
		else{//按标识查询，精确查询
			String strDefinex = "";
			
			strDefinex="(2=1 "+strDefinex+")";
			params.put("definex",strDefinex);
		}
		
		/************LAZY3Q_CODE_FIND************/
		/************LAZY3Q_CODE_FIND************/
		return InvitRecord.getInvitRecord(params);
	}
	
	
	/**
	 * 根据关键字查询邀请记录
	 * @return
	 */
	public static @api List<Map> query(String key,int size,Map params,Boolean bObject){
		if(Utils.empty((String)params.get("asc")) && Utils.empty((String)params.get("desc")))//如果未传入排序字段
			params.put("desc","id");//那么，默认以主键降序，传给Dao层
		String strTerm=key;		
		if(!Utils.empty(strTerm)){
			if(strTerm.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
				params.put("id", strTerm.toLowerCase().replaceFirst("id:", ""));					
			else//按标识查询，模糊查询请带%
			{
				String strDefinex = "";
				
				strDefinex="(2=1 "+strDefinex+")";
				params.put("definex",strDefinex);
			}
		}
		
		
		/************LAZY3Q_CODE_QUERY************/
		/************LAZY3Q_CODE_QUERY************/
			
		List<InvitRecord> list = page(0,size,params).getResult();
		
		/**
		* OK!取到数据拼成放入Map中，[{value,text,object:{...}},...]
		* value:数据ID，text:数据标识,object,整个对象
		**/
		List<Map> result = new java.util.ArrayList();
		for(InvitRecord invitRecord:list){
			Map map = new HashMap();
			map.put("key",invitRecord.getId().toString());
			map.put("value", Utils.js(invitRecord.getKeyValue()));
			if(bObject==true)
				map.put("object",invitRecord);
			result.add(map);
		}
		
		
		/************LAZY3Q_AFTER_QUERY************/
		/************LAZY3Q_AFTER_QUERY************/
		
		return result;
	}
	
	
	
	/**
	 * 获取所有邀请记录
	 * @return
	 */
	public static @api List<InvitRecord> getInvitRecordList(Map params,Integer size){
		return getInvitRecordDao().getInvitRecordList(params,0,size);
	}
	
	/**
	 * 获取邀请记录分页
	 * @return
	 */
	public static @api Page<InvitRecord> getInvitRecordPage(Integer page,Integer size,Map params){
		if(page==null)page=0;
		if(size==null)size=20;
		return getInvitRecordDao().getInvitRecordPage(page, size , params);
	}
	
	/**
	 * 根据查询条件取邀请记录
	 * @param params
	 * @return
	 */
	public static @api InvitRecord getInvitRecord(Map params){
		return getInvitRecordDao().getInvitRecord(params);
	}
	
	/**
	 * 保存一个邀请记录
	 * @param invitRecord
	 * @return
	 */
	public static @api InvitRecord saveInvitRecord(InvitRecord invitRecord){
		return getInvitRecordDao().saveInvitRecord(invitRecord);
	}
	
	/**
	 * 根据条件更新邀请记录
	 * @param values
	 * @param params
	 */
	public static @api int updateInvitRecordByConfirm(Map values, Map params){
		return getInvitRecordDao().updateInvitRecordByConfirm(values,params);
	}
	
	/**
	 * 修改一个邀请记录
	 * @param invitRecord
	 * @return
	 */
	public static @api int updateInvitRecord(InvitRecord invitRecord){
		return getInvitRecordDao().updateInvitRecord(invitRecord);
	}
	
	/**
	 * 更新邀请记录非空字段
	 * @param invitRecord
	 */
	public static @api int updateInvitRecord$NotNull(InvitRecord invitRecord){
		return getInvitRecordDao().updateInvitRecord$NotNull(invitRecord);
	}
	
	/**
	 * 获取邀请记录数
	 * @return
	 */
	public static @api Long getInvitRecordCount(Map params){
		return getInvitRecordDao().getInvitRecordCount(params);
	}
		
		
	/**
	 * 获取邀请记录自定义求和表达式,比如求和:eval="sum(id)"
	 * @return
	 */	
	public static @api <T> T getInvitRecordEval(String eval,Map params){
		return getInvitRecordDao().getInvitRecordEval(eval,params);
	}
	
	
	/**
	 * 获取邀请记录图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> getInvitRecordStats(Map params,C sumKey,C groupKey,int dateType){
		//TODO:图表统计功能未实现
		
		Map<String,Object> groups=new HashMap();//要分组的字段
		Map<String,Object> sums=new HashMap();//要统计的字段
		
		String[][] dateFormats=new String[][]{
				null,
				new String[]{"%Y","yyyy年","Y"},
				new String[]{"%Y-%m","yyyy年MM月","M"},
				new String[]{"%Y%U","yyyy年第ww周","W"},
				new String[]{"%Y-%m-%d","yyyy年MM月dd日","D"},
				new String[]{"%Y-%m-%d %H","yyyy年MM月dd日 HH点","H"},
				new String[]{"%m","MM月"},
				new String[]{"%d","dd号"},
				new String[]{"%H","HH点"} 
		};
		
		//获取要分组的字段，放入Map中
		if(dateType>0){
			groups.put(groupKey.toString(),"DATE_FORMAT({key},'"+dateFormats[dateType][0]+"')");
		}else{
			groups.put(groupKey.toString(),"{key}");
		}
		if(dateType<6 && dateType>0){ 
			params.put("asc", groupKey.toString()); 
			if(params.get(groupKey.name()+"Start")==null){
				params.put(groupKey.name()+"Start", Utils.date(new Date(), -24, dateFormats[dateType][2]));
			}
		}
		
		
		//获取要统计的字段，放入Map中
		if(sumKey.toString().equals("count")){
			sums.put(sumKey.toString(),"count(*)");
		}else{
			sums.put(sumKey.toString(),"sum({key})");
		}
		
		List<Map> list = getInvitRecordDao().getInvitRecordStats(params,groups,sums);
		
		List<Map> result = new ArrayList();
		for(Map m:list){
			Map map = new HashMap();
			Object value = m.get(sumKey.toString());
			Object name = null;
			Object groupValue = m.get(groupKey.toString());
			if(dateType>0){
				name = Utils.date(Utils.parseDate(groupValue), dateFormats[dateType][1]);
			}else{
				try{
					java.lang.reflect.Method method = InvitRecord.class.getMethod("get"+Utils.ForMat(groupKey.toString())+"$");
					method.setAccessible(true);
					name = method.invoke(InvitRecord.fromMap(m));
				}catch(Exception ex){
					ex.printStackTrace();
				}
			}
			map.put("name", name);
			map.put("value", value);
			result.add(map);
		}
		return result;
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static int updateInvitRecord(Map set,Map where){
		if(set.isEmpty())throw new RuntimeException("set为空");
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		return getInvitRecordDao().updateInvitRecordByConfirm(set, where);
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void deleteInvitRecord(Map where){
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		getInvitRecordDao().deleteInvitRecordByConfirm(where);
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void delete(Long id){
		if(id==null)throw new RuntimeException("id为空");
		
		getInvitRecordDao().removeInvitRecordById(id);
		
	}
	
	
	/**
	 * 保存邀请记录对象
	 * @param params
	 * @return
	 */
	public InvitRecord save(){
		if(this.getId()!=null)
			getInvitRecordDao().updateInvitRecord(this);
		else
			return getInvitRecordDao().saveInvitRecord(this);
		return this;
	}
	
	
	/**
	 * 更新邀请记录对象的非空字段,注意跟Service里面的update不一样哦
	 * @param params
	 * @return
	 */
	public int update(){
		return getInvitRecordDao().updateInvitRecord$NotNull(this);
	}
	
	
	/**
	 * 删除
	 * @param params
	 * @return
	 */
	public void delete(){
		
		if(Utils.equals(Utils.config("logic_delete"),"true"))
			getInvitRecordDao().removeInvitRecordById(this.getId());
		else
		
			getInvitRecordDao().deleteInvitRecordById(this.getId());
	}
	
	/**
	 * 执行事务
	 * @param function
	 */
	public static <T> T execute(Function function){
		return getInvitRecordDao().executeTransaction(function);
	}

	
	
	/*******************************编号**********************************/	
	/**
	* 编号 [非空]      
	**/
	public Long getId(){
		
		if(this.id!=null){
			return this.id;
		}
		
		return this.id;
	}
	/**
	* 获取编号格式化(toString)
	**/
	public String getId$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getId());
	 
	 	 return strValue;
	}
	/**
	* 根据编号反格式化
	**/
	public void setId$(String strValue){
		if(Utils.empty(strValue)){
			this.id=null;
			return;
		}
	
	
	 	this.id=Utils.parseLong(strValue);
	 
	}
	
	/**
	* 编号 [非空]      
	**/
	public void setId(Long id){
		this.id = id;
		
		this.setSeted(F.id);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************品牌**********************************/	
	/**
	* 品牌  [Merchant]     
	**/
	public Long getBrand(){
		
		if(this.brand!=null){
			return this.brand;
		}
		
		return this.brand;
	}
	/**
	* 获取品牌格式化(toString)
	**/
	public String getBrand$(){
		String strValue="";
	
	
		 
		if(this.getBrand()!=null){
			
				strValue+=Utils.string(Merchant.getKeyValue(this.getBrand()));
			
		}			
		 
	 
	 	 return strValue;
	}
	/**
	* 根据品牌反格式化
	**/
	public void setBrand$(String strValue){
		if(Utils.empty(strValue)){
			this.brand=null;
			return;
		}
	
	
		 
		Merchant item = Merchant.find(strValue);
		if(item!=null){
			
			this.brand = Utils.parseLong(item.getId());
			
		}
		 
	 
	}
	
	/**
	* 品牌  [Merchant]     
	**/
	public void setBrand(Long brand){
		this.brand = brand;
		
		this.setSeted(F.brand);
		
	}
	
	
		 
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 		
	/**
	* 获取关联对象[品牌信息]
	**/	 			
 	public Merchant get$brand(){
 		if(this.$brand!=null)
 			return this.$brand;
 		com.distribute.framework.model.Merchant merchant = null;
		if(this.getBrand()!=null){
		
 			merchant = Merchant.get(this.getBrand());
 		
 		}
 		return merchant;
	}
	
 	
	
	
	/*******************************被邀人**********************************/	
	/**
	* 被邀人 [非空] [Member]     
	**/
	public Long getInvitedPerson(){
		
		if(this.invitedPerson!=null){
			return this.invitedPerson;
		}
		
		return this.invitedPerson;
	}
	/**
	* 获取被邀人格式化(toString)
	**/
	public String getInvitedPerson$(){
		String strValue="";
	
	
		 
		if(this.getInvitedPerson()!=null){
			
				strValue+=Utils.string(Member.getKeyValue(this.getInvitedPerson()));
			
		}			
		 
	 
	 	 return strValue;
	}
	/**
	* 根据被邀人反格式化
	**/
	public void setInvitedPerson$(String strValue){
		if(Utils.empty(strValue)){
			this.invitedPerson=null;
			return;
		}
	
	
		 
		Member item = Member.find(strValue);
		if(item!=null){
			
			this.invitedPerson = Utils.parseLong(item.getUid());
			
		}
		 
	 
	}
	
	/**
	* 被邀人 [非空] [Member]     
	**/
	public void setInvitedPerson(Long invitedPerson){
		this.invitedPerson = invitedPerson;
		
		this.setSeted(F.invitedPerson);
		
	}
	
	
		 
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 		
	/**
	* 获取关联对象[会员信息]
	**/	 			
 	public Member get$invitedPerson(){
 		if(this.$invitedPerson!=null)
 			return this.$invitedPerson;
 		com.distribute.framework.model.Member member = null;
		if(this.getInvitedPerson()!=null){
		
 			member = Member.get(this.getInvitedPerson());
 		
 		}
 		return member;
	}
	
 	
	
	
	/*******************************折扣券ID**********************************/	
	/**
	* 折扣券ID  [Coupon]     
	**/
	public Long getInvitedCoupon(){
		
		if(this.invitedCoupon!=null){
			return this.invitedCoupon;
		}
		
		return this.invitedCoupon;
	}
	/**
	* 获取折扣券ID格式化(toString)
	**/
	public String getInvitedCoupon$(){
		String strValue="";
	
	
		 
		if(this.getInvitedCoupon()!=null){
			
				strValue+=Utils.string(Coupon.getKeyValue(this.getInvitedCoupon()));
			
		}			
		 
	 
	 	 return strValue;
	}
	/**
	* 根据折扣券ID反格式化
	**/
	public void setInvitedCoupon$(String strValue){
		if(Utils.empty(strValue)){
			this.invitedCoupon=null;
			return;
		}
	
	
		 
		Coupon item = Coupon.find(strValue);
		if(item!=null){
			
			this.invitedCoupon = Utils.parseLong(item.getId());
			
		}
		 
	 
	}
	
	/**
	* 折扣券ID  [Coupon]     
	**/
	public void setInvitedCoupon(Long invitedCoupon){
		this.invitedCoupon = invitedCoupon;
		
		this.setSeted(F.invitedCoupon);
		
	}
	
	
		 
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 		
	/**
	* 获取关联对象[用户优惠券]
	**/	 			
 	public Coupon get$invitedCoupon(){
 		if(this.$invitedCoupon!=null)
 			return this.$invitedCoupon;
 		com.distribute.framework.model.Coupon coupon = null;
		if(this.getInvitedCoupon()!=null){
		
 			coupon = Coupon.get(this.getInvitedCoupon());
 		
 		}
 		return coupon;
	}
	
 	
	
	
	/*******************************受邀折扣**********************************/	
	/**
	* 受邀折扣       
	**/
	public Double getInvitedDiscount(){
		
		if(this.invitedDiscount!=null){
			return this.invitedDiscount;
		}
		
		return this.invitedDiscount;
	}
	/**
	* 获取受邀折扣格式化(toString)
	**/
	public String getInvitedDiscount$(){
		String strValue="";
	
	
			
		 strValue=Utils.string(this.getInvitedDiscount());	
			
	 
	 	 return strValue;
	}
	/**
	* 根据受邀折扣反格式化
	**/
	public void setInvitedDiscount$(String strValue){
		if(Utils.empty(strValue)){
			this.invitedDiscount=null;
			return;
		}
	
	
	 	this.invitedDiscount=Utils.parseDouble(strValue);
	 
	}
	
	/**
	* 受邀折扣       
	**/
	public void setInvitedDiscount(Double invitedDiscount){
		this.invitedDiscount = invitedDiscount;
		
		this.setSeted(F.invitedDiscount);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************推荐人**********************************/	
	/**
	* 推荐人 [非空] [Member]     
	**/
	public Long getRecom(){
		
		if(this.recom!=null){
			return this.recom;
		}
		
		return this.recom;
	}
	/**
	* 获取推荐人格式化(toString)
	**/
	public String getRecom$(){
		String strValue="";
	
	
		 
		if(this.getRecom()!=null){
			
				strValue+=Utils.string(Member.getKeyValue(this.getRecom()));
			
		}			
		 
	 
	 	 return strValue;
	}
	/**
	* 根据推荐人反格式化
	**/
	public void setRecom$(String strValue){
		if(Utils.empty(strValue)){
			this.recom=null;
			return;
		}
	
	
		 
		Member item = Member.find(strValue);
		if(item!=null){
			
			this.recom = Utils.parseLong(item.getUid());
			
		}
		 
	 
	}
	
	/**
	* 推荐人 [非空] [Member]     
	**/
	public void setRecom(Long recom){
		this.recom = recom;
		
		this.setSeted(F.recom);
		
	}
	
	
		 
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 		
	/**
	* 获取关联对象[会员信息]
	**/	 			
 	public Member get$recom(){
 		if(this.$recom!=null)
 			return this.$recom;
 		com.distribute.framework.model.Member member = null;
		if(this.getRecom()!=null){
		
 			member = Member.get(this.getRecom());
 		
 		}
 		return member;
	}
	
 	
	
	
	/*******************************折扣券ID**********************************/	
	/**
	* 折扣券ID  [Coupon]     
	**/
	public Long getRecomCoupon(){
		
		if(this.recomCoupon!=null){
			return this.recomCoupon;
		}
		
		return this.recomCoupon;
	}
	/**
	* 获取折扣券ID格式化(toString)
	**/
	public String getRecomCoupon$(){
		String strValue="";
	
	
		 
		if(this.getRecomCoupon()!=null){
			
				strValue+=Utils.string(Coupon.getKeyValue(this.getRecomCoupon()));
			
		}			
		 
	 
	 	 return strValue;
	}
	/**
	* 根据折扣券ID反格式化
	**/
	public void setRecomCoupon$(String strValue){
		if(Utils.empty(strValue)){
			this.recomCoupon=null;
			return;
		}
	
	
		 
		Coupon item = Coupon.find(strValue);
		if(item!=null){
			
			this.recomCoupon = Utils.parseLong(item.getId());
			
		}
		 
	 
	}
	
	/**
	* 折扣券ID  [Coupon]     
	**/
	public void setRecomCoupon(Long recomCoupon){
		this.recomCoupon = recomCoupon;
		
		this.setSeted(F.recomCoupon);
		
	}
	
	
		 
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 		
	/**
	* 获取关联对象[用户优惠券]
	**/	 			
 	public Coupon get$recomCoupon(){
 		if(this.$recomCoupon!=null)
 			return this.$recomCoupon;
 		com.distribute.framework.model.Coupon coupon = null;
		if(this.getRecomCoupon()!=null){
		
 			coupon = Coupon.get(this.getRecomCoupon());
 		
 		}
 		return coupon;
	}
	
 	
	
	
	/*******************************折扣**********************************/	
	/**
	* 折扣       
	**/
	public Double getRecomDiscount(){
		
		if(this.recomDiscount!=null){
			return this.recomDiscount;
		}
		
		return this.recomDiscount;
	}
	/**
	* 获取折扣格式化(toString)
	**/
	public String getRecomDiscount$(){
		String strValue="";
	
	
			
		 strValue=Utils.string(this.getRecomDiscount());	
			
	 
	 	 return strValue;
	}
	/**
	* 根据折扣反格式化
	**/
	public void setRecomDiscount$(String strValue){
		if(Utils.empty(strValue)){
			this.recomDiscount=null;
			return;
		}
	
	
	 	this.recomDiscount=Utils.parseDouble(strValue);
	 
	}
	
	/**
	* 折扣       
	**/
	public void setRecomDiscount(Double recomDiscount){
		this.recomDiscount = recomDiscount;
		
		this.setSeted(F.recomDiscount);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************邀请类型**********************************/	
	/**
	* 邀请类型    1:新人邀请 2:老用户回归    
	**/
	public Short getInvitrType(){
		
		if(this.invitrType!=null){
			return this.invitrType;
		}
		
		return this.invitrType;
	}
	/**
	* 获取邀请类型格式化(toString)
	**/
	public String getInvitrType$(){
		String strValue="";
	
	
		
			
		 if(Utils.equals(Utils.string(this.getInvitrType()),"1"))
			strValue=Utils.string("新人邀请");		 
			
		 if(Utils.equals(Utils.string(this.getInvitrType()),"2"))
			strValue=Utils.string("老用户回归");		 
			
		
	 
	 	 return strValue;
	}
	/**
	* 根据邀请类型反格式化
	**/
	public void setInvitrType$(String strValue){
		if(Utils.empty(strValue)){
			this.invitrType=null;
			return;
		}
	
	
		
			
		 if(Utils.equals(strValue,"新人邀请"))
		 	this.invitrType=Utils.parseShort("1");
			
		 if(Utils.equals(strValue,"老用户回归"))
		 	this.invitrType=Utils.parseShort("2");
			
		
	 
	}
	
	/**
	* 邀请类型    1:新人邀请 2:老用户回归    
	**/
	public void setInvitrType(Short invitrType){
		this.invitrType = invitrType;
		
		this.setSeted(F.invitrType);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************修改时间**********************************/	
	/**
	* 修改时间 [非空]      
	**/
	public Date getUpdateTime(){
		
		if(this.updateTime!=null){
			return this.updateTime;
		}
		
		return this.updateTime;
	}
	/**
	* 获取修改时间格式化(toString)
	**/
	public String getUpdateTime$(){
		String strValue="";
	
	
	 	
		 strValue=Utils.string(Utils.date(this.getUpdateTime(),"yyyy-MM-dd HH:mm:ss"));
		
	 
	 	 return strValue;
	}
	/**
	* 根据修改时间反格式化
	**/
	public void setUpdateTime$(String strValue){
		if(Utils.empty(strValue)){
			this.updateTime=null;
			return;
		}
	
	
	 	this.updateTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	 
	}
	
	/**
	* 修改时间 [非空]      
	**/
	public void setUpdateTime(Date updateTime){
		this.updateTime = updateTime;
		
		this.setSeted(F.updateTime);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************添加时间**********************************/	
	/**
	* 添加时间 [非空]      
	**/
	public Date getAddTime(){
		
		if(this.addTime!=null){
			return this.addTime;
		}
		
		return this.addTime;
	}
	/**
	* 获取添加时间格式化(toString)
	**/
	public String getAddTime$(){
		String strValue="";
	
	
	 	
		 strValue=Utils.string(Utils.date(this.getAddTime(),"yyyy-MM-dd HH:mm:ss"));
		
	 
	 	 return strValue;
	}
	/**
	* 根据添加时间反格式化
	**/
	public void setAddTime$(String strValue){
		if(Utils.empty(strValue)){
			this.addTime=null;
			return;
		}
	
	
	 	this.addTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	 
	}
	
	/**
	* 添加时间 [非空]      
	**/
	public void setAddTime(Date addTime){
		this.addTime = addTime;
		
		this.setSeted(F.addTime);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************状态**********************************/	
	/**
	* 状态 [非空]   1:正常 0:无效    
	**/
	public Short getStatus(){
		
		if(this.status!=null){
			return this.status;
		}
		
		return this.status;
	}
	/**
	* 获取状态格式化(toString)
	**/
	public String getStatus$(){
		String strValue="";
	
	
		
			
		 if(Utils.equals(Utils.string(this.getStatus()),"1"))
			strValue=Utils.string("正常");		 
			
		 if(Utils.equals(Utils.string(this.getStatus()),"0"))
			strValue=Utils.string("无效");		 
			
		
	 
	 	 return strValue;
	}
	/**
	* 根据状态反格式化
	**/
	public void setStatus$(String strValue){
		if(Utils.empty(strValue)){
			this.status=null;
			return;
		}
	
	
		
			
		 if(Utils.equals(strValue,"正常"))
		 	this.status=Utils.parseShort("1");
			
		 if(Utils.equals(strValue,"无效"))
		 	this.status=Utils.parseShort("0");
			
		
	 
	}
	
	/**
	* 状态 [非空]   1:正常 0:无效    
	**/
	public void setStatus(Short status){
		this.status = status;
		
		this.setSeted(F.status);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	
	/************LAZY3Q_DEFINE_CODE************/
	/************LAZY3Q_DEFINE_CODE************/	
	
	
	/**
	 * 触发器
	 */
	public static void on(Trigger.Index index,final Notify.Listener listener,Trigger.Type... types){
		Notify.on(InvitRecord.class, index, listener, types);
	}
	public static void on(final Notify.Listener listener,String type){
		Notify.on(InvitRecord.class, listener, type);
	}
	/**
	 * 当修改字段时
	 * @param filedName
	 * @param listener
	 */
	public static void on(String filedName,final Notify.Listener listener){
		Notify.on(InvitRecord.class, listener, filedName);
	}
	/**
	 * 当修改字段为某值时
	 * @param filedName
	 * @param value
	 * @param listener
	 */
	public static void on(String filedName,Object value,final Notify.Listener listener){
		if(value==null)return;
		Notify.on(InvitRecord.class, listener, filedName+"."+Utils.md5(""+value));
	}
	public void notify(String type){
		Trigger.on(InvitRecord.class,type, this);
	}
	
	
	/**
	 * 用来获取当有字段关联对象时的获取方式,调用如${InvitRecord.obj.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${InvitRecord.$filedName}获取关联对象
	 */
	public Map getObj(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return InvitRecord.class.getMethod("get$"+Utils.forMat(key.toString())).invoke(InvitRecord.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 用来获取某字段格式化的获取方式,调用如${InvitRecord.fmt.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${InvitRecord.filedName$}获取某字段格式化
	 */
	public Map getFmt(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return InvitRecord.class.getMethod("get"+Utils.ForMat(key.toString()+"$")).invoke(InvitRecord.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 获取查询参数链式串
	 * @return
	 */
	public static @Deprecated M where(){ return new M(0); }
	public static @Deprecated M m(){ return new M(0); }
	public static M where = new M(0,true);
	public static @database(DatabaseNames.distribute_sys) class M extends IbatisMap{
		int type = 0; 
		M linked = null;
		Boolean proxy = false;
		public M set = null;
		public M(int type){
			this.type = type;
			if(this.type==0){
				set = new M(1,true);
				set.linked = this;
			}
		};
		public M(int type,Boolean proxy){
			this.type = type;
			this.proxy=proxy;
		};
		public M proxy(){
			M m = new M(this.type);//当前的对像
			if(this.type==0){
				m.set = new M(1,true);//set对象
				m.set.linked = m;
			}else{
				m.linked=this.linked;
				this.linked.linked=m;
			}
			return m;
		}
		public @Deprecated M set(){			
			M m = this;
			m.linked=new M(1);
			m.linked.linked=m;
			return m.linked;
		};
		
		public M on(IbatisMap value,C column,String joinColumn){if(proxy)return proxy().on(value,column,joinColumn);this.put(value.getClass().getDeclaringClass().getSimpleName(), value);value.put("on", column.toString());value.put("to", joinColumn);return this;};
		
		
			
		
		/** 编号 [非空]       **/
		public M id(Object id){if(proxy)return proxy().id(id);  this.put("id", id);return this;};
	 	/** and id is null */
 		public M idNull(){if(proxy)return proxy().idNull();if(this.get("idNot")==null)this.put("idNot", "");this.put("id", null);return this;};
 		/** not .... */
 		public M idNot(){if(proxy)return proxy().idNot();this.put("idNot", "not");return this;};
 		public M idNotNull(){if(proxy)return proxy().idNotNull();this.put("idNot", "not");this.put("id", null);return this;};
 		public M idNot(Object id){if(proxy)return proxy().idNot(id);this.put("idNot", "not");this.put("id", id);return this;};
	 		
		/** and id <= ? */
		public M idMin(Object min){if(proxy)return proxy().idMin(min);this.put("idMin", min);return this;};
		/** and id >= ? */
		public M idMax(Object max){if(proxy)return proxy().idMax(max);this.put("idMax", max);return this;};
			
			
		public M idIn(String ids){
			if(proxy)return proxy().idIn(ids);  this.put("idIn", ids);return this;
		};	
 			
		
			
	 	
			
		public M brand$on(Merchant.M value){if(proxy)return proxy().brand$on(value);this.put("Brand", value);value.put("on", "brand");return this;};
 				
 			
		
		/** 品牌  [Merchant]      **/
		public M brand(Object brand){if(proxy)return proxy().brand(brand);  this.put("brand", brand);return this;};
	 	/** and brand is null */
 		public M brandNull(){if(proxy)return proxy().brandNull();if(this.get("brandNot")==null)this.put("brandNot", "");this.put("brand", null);return this;};
 		/** not .... */
 		public M brandNot(){if(proxy)return proxy().brandNot();this.put("brandNot", "not");return this;};
 		public M brandNotNull(){if(proxy)return proxy().brandNotNull();this.put("brandNot", "not");this.put("brand", null);return this;};
 		public M brandNot(Object brand){if(proxy)return proxy().brandNot(brand);this.put("brandNot", "not");this.put("brand", brand);return this;};
	 		
			
		public M brandIn(String ids){
			if(proxy)return proxy().brandIn(ids);  this.put("brandIn", ids);return this;
		};	
 			
		
			
	 	
			
		public M invitedPerson$on(Member.M value){if(proxy)return proxy().invitedPerson$on(value);this.put("InvitedPerson", value);value.put("on", "invited_person");return this;};
 				
 			
		
		/** 被邀人 [非空] [Member]      **/
		public M invitedPerson(Object invitedPerson){if(proxy)return proxy().invitedPerson(invitedPerson);  this.put("invitedPerson", invitedPerson);return this;};
	 	/** and invited_person is null */
 		public M invitedPersonNull(){if(proxy)return proxy().invitedPersonNull();if(this.get("invitedPersonNot")==null)this.put("invitedPersonNot", "");this.put("invitedPerson", null);return this;};
 		/** not .... */
 		public M invitedPersonNot(){if(proxy)return proxy().invitedPersonNot();this.put("invitedPersonNot", "not");return this;};
 		public M invitedPersonNotNull(){if(proxy)return proxy().invitedPersonNotNull();this.put("invitedPersonNot", "not");this.put("invitedPerson", null);return this;};
 		public M invitedPersonNot(Object invitedPerson){if(proxy)return proxy().invitedPersonNot(invitedPerson);this.put("invitedPersonNot", "not");this.put("invitedPerson", invitedPerson);return this;};
	 		
			
		public M invitedPersonIn(String ids){
			if(proxy)return proxy().invitedPersonIn(ids);  this.put("invitedPersonIn", ids);return this;
		};	
 			
		
			
	 	
			
		public M invitedCoupon$on(Coupon.M value){if(proxy)return proxy().invitedCoupon$on(value);this.put("InvitedCoupon", value);value.put("on", "invited_coupon");return this;};
 				
 			
		
		/** 折扣券ID  [Coupon]      **/
		public M invitedCoupon(Object invitedCoupon){if(proxy)return proxy().invitedCoupon(invitedCoupon);  this.put("invitedCoupon", invitedCoupon);return this;};
	 	/** and invited_coupon is null */
 		public M invitedCouponNull(){if(proxy)return proxy().invitedCouponNull();if(this.get("invitedCouponNot")==null)this.put("invitedCouponNot", "");this.put("invitedCoupon", null);return this;};
 		/** not .... */
 		public M invitedCouponNot(){if(proxy)return proxy().invitedCouponNot();this.put("invitedCouponNot", "not");return this;};
 		public M invitedCouponNotNull(){if(proxy)return proxy().invitedCouponNotNull();this.put("invitedCouponNot", "not");this.put("invitedCoupon", null);return this;};
 		public M invitedCouponNot(Object invitedCoupon){if(proxy)return proxy().invitedCouponNot(invitedCoupon);this.put("invitedCouponNot", "not");this.put("invitedCoupon", invitedCoupon);return this;};
	 		
			
		public M invitedCouponIn(String ids){
			if(proxy)return proxy().invitedCouponIn(ids);  this.put("invitedCouponIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 受邀折扣        **/
		public M invitedDiscount(Object invitedDiscount){if(proxy)return proxy().invitedDiscount(invitedDiscount);  this.put("invitedDiscount", invitedDiscount);return this;};
	 	/** and invited_discount is null */
 		public M invitedDiscountNull(){if(proxy)return proxy().invitedDiscountNull();if(this.get("invitedDiscountNot")==null)this.put("invitedDiscountNot", "");this.put("invitedDiscount", null);return this;};
 		/** not .... */
 		public M invitedDiscountNot(){if(proxy)return proxy().invitedDiscountNot();this.put("invitedDiscountNot", "not");return this;};
 		public M invitedDiscountNotNull(){if(proxy)return proxy().invitedDiscountNotNull();this.put("invitedDiscountNot", "not");this.put("invitedDiscount", null);return this;};
 		public M invitedDiscountNot(Object invitedDiscount){if(proxy)return proxy().invitedDiscountNot(invitedDiscount);this.put("invitedDiscountNot", "not");this.put("invitedDiscount", invitedDiscount);return this;};
	 		
		/** and invited_discount <= ? */
		public M invitedDiscountMin(Object min){if(proxy)return proxy().invitedDiscountMin(min);this.put("invitedDiscountMin", min);return this;};
		/** and invited_discount >= ? */
		public M invitedDiscountMax(Object max){if(proxy)return proxy().invitedDiscountMax(max);this.put("invitedDiscountMax", max);return this;};
			
			
		
			
	 	
			
		public M recom$on(Member.M value){if(proxy)return proxy().recom$on(value);this.put("Recom", value);value.put("on", "recom");return this;};
 				
 			
		
		/** 推荐人 [非空] [Member]      **/
		public M recom(Object recom){if(proxy)return proxy().recom(recom);  this.put("recom", recom);return this;};
	 	/** and recom is null */
 		public M recomNull(){if(proxy)return proxy().recomNull();if(this.get("recomNot")==null)this.put("recomNot", "");this.put("recom", null);return this;};
 		/** not .... */
 		public M recomNot(){if(proxy)return proxy().recomNot();this.put("recomNot", "not");return this;};
 		public M recomNotNull(){if(proxy)return proxy().recomNotNull();this.put("recomNot", "not");this.put("recom", null);return this;};
 		public M recomNot(Object recom){if(proxy)return proxy().recomNot(recom);this.put("recomNot", "not");this.put("recom", recom);return this;};
	 		
			
		public M recomIn(String ids){
			if(proxy)return proxy().recomIn(ids);  this.put("recomIn", ids);return this;
		};	
 			
		
			
	 	
			
		public M recomCoupon$on(Coupon.M value){if(proxy)return proxy().recomCoupon$on(value);this.put("RecomCoupon", value);value.put("on", "recom_coupon");return this;};
 				
 			
		
		/** 折扣券ID  [Coupon]      **/
		public M recomCoupon(Object recomCoupon){if(proxy)return proxy().recomCoupon(recomCoupon);  this.put("recomCoupon", recomCoupon);return this;};
	 	/** and recom_coupon is null */
 		public M recomCouponNull(){if(proxy)return proxy().recomCouponNull();if(this.get("recomCouponNot")==null)this.put("recomCouponNot", "");this.put("recomCoupon", null);return this;};
 		/** not .... */
 		public M recomCouponNot(){if(proxy)return proxy().recomCouponNot();this.put("recomCouponNot", "not");return this;};
 		public M recomCouponNotNull(){if(proxy)return proxy().recomCouponNotNull();this.put("recomCouponNot", "not");this.put("recomCoupon", null);return this;};
 		public M recomCouponNot(Object recomCoupon){if(proxy)return proxy().recomCouponNot(recomCoupon);this.put("recomCouponNot", "not");this.put("recomCoupon", recomCoupon);return this;};
	 		
			
		public M recomCouponIn(String ids){
			if(proxy)return proxy().recomCouponIn(ids);  this.put("recomCouponIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 折扣        **/
		public M recomDiscount(Object recomDiscount){if(proxy)return proxy().recomDiscount(recomDiscount);  this.put("recomDiscount", recomDiscount);return this;};
	 	/** and recom_discount is null */
 		public M recomDiscountNull(){if(proxy)return proxy().recomDiscountNull();if(this.get("recomDiscountNot")==null)this.put("recomDiscountNot", "");this.put("recomDiscount", null);return this;};
 		/** not .... */
 		public M recomDiscountNot(){if(proxy)return proxy().recomDiscountNot();this.put("recomDiscountNot", "not");return this;};
 		public M recomDiscountNotNull(){if(proxy)return proxy().recomDiscountNotNull();this.put("recomDiscountNot", "not");this.put("recomDiscount", null);return this;};
 		public M recomDiscountNot(Object recomDiscount){if(proxy)return proxy().recomDiscountNot(recomDiscount);this.put("recomDiscountNot", "not");this.put("recomDiscount", recomDiscount);return this;};
	 		
		/** and recom_discount <= ? */
		public M recomDiscountMin(Object min){if(proxy)return proxy().recomDiscountMin(min);this.put("recomDiscountMin", min);return this;};
		/** and recom_discount >= ? */
		public M recomDiscountMax(Object max){if(proxy)return proxy().recomDiscountMax(max);this.put("recomDiscountMax", max);return this;};
			
			
		
			
	 	
			
		
		/** 邀请类型    1:新人邀请 2:老用户回归     **/
		public M invitrType(Object invitrType){if(proxy)return proxy().invitrType(invitrType);  this.put("invitrType", invitrType);return this;};
	 	/** and invitr_type is null */
 		public M invitrTypeNull(){if(proxy)return proxy().invitrTypeNull();if(this.get("invitrTypeNot")==null)this.put("invitrTypeNot", "");this.put("invitrType", null);return this;};
 		/** not .... */
 		public M invitrTypeNot(){if(proxy)return proxy().invitrTypeNot();this.put("invitrTypeNot", "not");return this;};
 		public M invitrTypeNotNull(){if(proxy)return proxy().invitrTypeNotNull();this.put("invitrTypeNot", "not");this.put("invitrType", null);return this;};
 		public M invitrTypeNot(Object invitrType){if(proxy)return proxy().invitrTypeNot(invitrType);this.put("invitrTypeNot", "not");this.put("invitrType", invitrType);return this;};
	 		
			
		public M invitrTypeIn(String ids){
			if(proxy)return proxy().invitrTypeIn(ids);  this.put("invitrTypeIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 修改时间 [非空]       **/
		public M updateTime(Object updateTime){if(proxy)return proxy().updateTime(updateTime);  this.put("updateTime", updateTime);return this;};
	 	/** and update_time is null */
 		public M updateTimeNull(){if(proxy)return proxy().updateTimeNull();if(this.get("updateTimeNot")==null)this.put("updateTimeNot", "");this.put("updateTime", null);return this;};
 		/** not .... */
 		public M updateTimeNot(){if(proxy)return proxy().updateTimeNot();this.put("updateTimeNot", "not");return this;};
 		public M updateTimeNotNull(){if(proxy)return proxy().updateTimeNotNull();this.put("updateTimeNot", "not");this.put("updateTime", null);return this;};
 		public M updateTimeNot(Object updateTime){if(proxy)return proxy().updateTimeNot(updateTime);this.put("updateTimeNot", "not");this.put("updateTime", updateTime);return this;};
	 		
 		/** and update_time >= ? */
 		public M updateTimeStart(Object start){if(proxy)return proxy().updateTimeStart(start);this.put("updateTimeStart", start);return this;};			
 		/** and update_time <= ? */
 		public M updateTimeEnd(Object end){if(proxy)return proxy().updateTimeEnd(end);this.put("updateTimeEnd", end);return this;};
			
			
		
			
	 	
			
		
		/** 添加时间 [非空]       **/
		public M addTime(Object addTime){if(proxy)return proxy().addTime(addTime);  this.put("addTime", addTime);return this;};
	 	/** and add_time is null */
 		public M addTimeNull(){if(proxy)return proxy().addTimeNull();if(this.get("addTimeNot")==null)this.put("addTimeNot", "");this.put("addTime", null);return this;};
 		/** not .... */
 		public M addTimeNot(){if(proxy)return proxy().addTimeNot();this.put("addTimeNot", "not");return this;};
 		public M addTimeNotNull(){if(proxy)return proxy().addTimeNotNull();this.put("addTimeNot", "not");this.put("addTime", null);return this;};
 		public M addTimeNot(Object addTime){if(proxy)return proxy().addTimeNot(addTime);this.put("addTimeNot", "not");this.put("addTime", addTime);return this;};
	 		
 		/** and add_time >= ? */
 		public M addTimeStart(Object start){if(proxy)return proxy().addTimeStart(start);this.put("addTimeStart", start);return this;};			
 		/** and add_time <= ? */
 		public M addTimeEnd(Object end){if(proxy)return proxy().addTimeEnd(end);this.put("addTimeEnd", end);return this;};
			
			
		
			
	 	
			
		
		/** 状态 [非空]   1:正常 0:无效     **/
		public M status(Object status){if(proxy)return proxy().status(status);  this.put("status", status);return this;};
	 	/** and status is null */
 		public M statusNull(){if(proxy)return proxy().statusNull();if(this.get("statusNot")==null)this.put("statusNot", "");this.put("status", null);return this;};
 		/** not .... */
 		public M statusNot(){if(proxy)return proxy().statusNot();this.put("statusNot", "not");return this;};
 		public M statusNotNull(){if(proxy)return proxy().statusNotNull();this.put("statusNot", "not");this.put("status", null);return this;};
 		public M statusNot(Object status){if(proxy)return proxy().statusNot(status);this.put("statusNot", "not");this.put("status", status);return this;};
	 		
			
		public M statusIn(String ids){
			if(proxy)return proxy().statusIn(ids);  this.put("statusIn", ids);return this;
		};	
 			
		
			
	 	
	 	public M add(String key, Object value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	 	public M add(F key, Object value) {if(proxy)return proxy().add(key,value);this.put(key.toString(), value);return this;}
	 	
	 	public M desc(C key) {if(proxy)return proxy().desc(key);this.put("desc", key.column);return this;}
	 	public M asc(C key) {if(proxy)return proxy().asc(key);this.put("asc", key.column);return this;}
	 	public M desc(String sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	 	public M asc(String sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	 	public M definex(String sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	 	
	 	/** 获取所有邀请记录 **/
		public @api List<InvitRecord> list(Integer size){			
			return getInvitRecordList(this,size);
		}
		/** 获取邀请记录分页 **/
		public @api Page<InvitRecord> page(Integer page,Integer size){			
			return getInvitRecordPage(page, size , this);
		}
		/** 根据查询条件取邀请记录 **/
		public @api InvitRecord get(){			
			return getInvitRecord(this);
		}
		/** 获取邀请记录数 **/
		public @api Long count(){			
			return getInvitRecordCount(this);
		}
		/** 获取邀请记录表达式 **/
		public @api <T> T eval(String strEval){			
			return getInvitRecordEval(strEval,this);
		}
		
		/** 获取邀请记录统计 **/
		public @api List<Map> stats(C sumKey,C groupKey,int dateType){			
			return getInvitRecordStats(this,sumKey,groupKey,dateType);
		}
		/** 获取邀请记录统计 **/
		public @api List<Map> stats(C sumKey,C groupKey){			
			return getInvitRecordStats(this,sumKey,groupKey,-1);
		}
		
		/** 根据条件更新 **/
		public @api int update(){			
			M where = null;
			M set = null;
			if(this.type==0){
				if(this.linked==null)throw new RuntimeException("未发set");
				where = this;
				set = this.linked;
			}else{
				if(this.linked==null)throw new RuntimeException("未发where条件");
				set = this;
				where = this.linked;
			}
			return updateInvitRecord(set,where);
		}
		/** 根据条件删除 **/
		public @api void delete(){			
			deleteInvitRecord(this);
		}
	}
	
	public static class Param extends M{
		public Param(int type) {
			super(type);
		}
		public Param(int type, Boolean proxy) {
			super(type, proxy);
		}
	}
	
	/** 对象的字段描述 **/
	public static class F{
		
			
		/** 编号 [非空]       **/
		public final static @type(Long.class)  String id="id";
	 			
			
	 	
			
		/** 品牌  [Merchant]      **/
		public final static @type(Long.class)  String brand="brand";
	 			
			
	 	
			
		/** 被邀人 [非空] [Member]      **/
		public final static @type(Long.class)  String invitedPerson="invitedPerson";
	 			
			
	 	
			
		/** 折扣券ID  [Coupon]      **/
		public final static @type(Long.class)  String invitedCoupon="invitedCoupon";
	 			
			
	 	
			
		/** 受邀折扣        **/
		public final static @type(Double.class)  String invitedDiscount="invitedDiscount";
	 			
		/** and invited_discount >= ? */
		public final static @type(Double.class) String invitedDiscountMin="invitedDiscountMin";
		/** and invited_discount <= ? */
		public final static @type(Double.class) String invitedDiscountMax="invitedDiscountMax";
				
			
	 	
			
		/** 推荐人 [非空] [Member]      **/
		public final static @type(Long.class)  String recom="recom";
	 			
			
	 	
			
		/** 折扣券ID  [Coupon]      **/
		public final static @type(Long.class)  String recomCoupon="recomCoupon";
	 			
			
	 	
			
		/** 折扣        **/
		public final static @type(Double.class)  String recomDiscount="recomDiscount";
	 			
		/** and recom_discount >= ? */
		public final static @type(Double.class) String recomDiscountMin="recomDiscountMin";
		/** and recom_discount <= ? */
		public final static @type(Double.class) String recomDiscountMax="recomDiscountMax";
				
			
	 	
			
		/** 邀请类型    1:新人邀请 2:老用户回归     **/
		public final static @type(Short.class)  String invitrType="invitrType";
	 			
			
	 	
			
		/** 修改时间 [非空]       **/
		public final static @type(Date.class)  String updateTime="updateTime";
	 			
	 	/** and update_time >= ? */
 		public final static @type(Date.class) String updateTimeStart="updateTimeStart";
 		/** and update_time <= ? */
 		public final static @type(Date.class) String updateTimeEnd="updateTimeEnd";
				
			
	 	
			
		/** 添加时间 [非空]       **/
		public final static @type(Date.class)  String addTime="addTime";
	 			
	 	/** and add_time >= ? */
 		public final static @type(Date.class) String addTimeStart="addTimeStart";
 		/** and add_time <= ? */
 		public final static @type(Date.class) String addTimeEnd="addTimeEnd";
				
			
	 	
			
		/** 状态 [非空]   1:正常 0:无效     **/
		public final static @type(Short.class)  String status="status";
	 			
			
	 	
	 	public static String get(String name){
			try {
				Field field = F.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	/** 对象的数据库字段描述 **/
	public static enum C{
		
		id("id"),
		brand("brand"),
		invitedPerson("invited_person"),
		invitedCoupon("invited_coupon"),
		invitedDiscount("invited_discount"),
		recom("recom"),
		recomCoupon("recom_coupon"),
		recomDiscount("recom_discount"),
		invitrType("invitr_type"),
		updateTime("update_time"),
		addTime("add_time"),
		status("status"),
		count("count");
		String column;
		C(String column){
			this.column = column;
		}
		public String toString(){
			return this.column;
		}
		public static String get(String name){
			try {
				Field field = C.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	
	/**
	* 获取邀请记录数据
	**/
	public static Object getData(Object param){
		if(param==null)
			return null;
		Object value = null;
		if(param.getClass()==Long.class)
			value = InvitRecord.get((Long)param);
		else if(param instanceof java.util.Map){
			java.util.Map params = (Map) param;
			if(params.get("size")==null)
				value = InvitRecord.getInvitRecord(params);
			else
				value = InvitRecord.getInvitRecordList(params, (Integer) params.get("size"));
		}else if(param.getClass()==Long.class )
			value =  InvitRecord.where().id(param).get();
		else if(!Utils.empty(param.toString()))
			value = InvitRecord.get(Long.valueOf(param.toString()));
		return value;
	}
	
	/**对象转json**/
	public Map toJSON(){
		return toJSON(false);
	}
	public Map toJSON(boolean simple){
		return toJSON(simple,0);
	}
	public Map toJSON(boolean simple,int step){
		Map map = new HashMap();
		map.put("id",this.getId());
	
		Utils.fms(map,simple?"":"id",this.getId(),this.getId$());
		
			
 		
	
		Utils.fms(map,simple?"":"brand",this.getBrand(),this.getBrand$());
		
			
 		
	
		Utils.fms(map,simple?"person":"invitedPerson",this.getInvitedPerson(),this.getInvitedPerson$());
		
			
 		
	
		Utils.fms(map,simple?"coupon":"invitedCoupon",this.getInvitedCoupon(),this.getInvitedCoupon$());
		
			
 		
	
		Utils.fms(map,simple?"discount":"invitedDiscount",this.getInvitedDiscount(),this.getInvitedDiscount$());
		
			
 		
	
		Utils.fms(map,simple?"":"recom",this.getRecom(),this.getRecom$());
		
			
 		
	
		Utils.fms(map,simple?"coupon":"recomCoupon",this.getRecomCoupon(),this.getRecomCoupon$());
		
			
 		
	
		Utils.fms(map,simple?"discount":"recomDiscount",this.getRecomDiscount(),this.getRecomDiscount$());
		
			
 		
	
		Utils.fms(map,simple?"type":"invitrType",this.getInvitrType(),this.getInvitrType$());
		
			
 		
	
		Utils.fms(map,simple?"time":"updateTime",this.getUpdateTime(),this.getUpdateTime$());
		
			
 		
	
		Utils.fms(map,simple?"time":"addTime",this.getAddTime(),this.getAddTime$());
		
			
 		
	
		Utils.fms(map,simple?"":"status",this.getStatus(),this.getStatus$());
		
			
 		
	
		if(this.suffix!=null)map.put("suffix", this.suffix);
		
		/************LAZY3Q_DEFINE_TOJSON************/
		/************LAZY3Q_DEFINE_TOJSON************/
		return map;
	}
	/**对象转map**/
	public Map toMap(){
		Map map = new HashMap();
	
		map.put("id",this.getId());
 		
	
		map.put("brand",this.getBrand());
 		
	
		map.put("invitedPerson",this.getInvitedPerson());
 		
	
		map.put("invitedCoupon",this.getInvitedCoupon());
 		
	
		map.put("invitedDiscount",this.getInvitedDiscount());
 		
	
		map.put("recom",this.getRecom());
 		
	
		map.put("recomCoupon",this.getRecomCoupon());
 		
	
		map.put("recomDiscount",this.getRecomDiscount());
 		
	
		map.put("invitrType",this.getInvitrType());
 		
	
		map.put("updateTime",this.getUpdateTime());
 		
	
		map.put("addTime",this.getAddTime());
 		
	
		map.put("status",this.getStatus());
 		
	
		map.put("suffix", this.suffix);
		
		/************LAZY3Q_DEFINE_TOMAP************/
		/************LAZY3Q_DEFINE_TOMAP************/
		return map;
	}
	/**map转对象**/
	public static InvitRecord fromMap(Map map){
		InvitRecord invitRecord = new InvitRecord();
	
		invitRecord.id = Utils.parseLong(map.get("id"));
 		
	
		invitRecord.brand = Utils.parseLong(map.get("brand"));
 		
	
		invitRecord.invitedPerson = Utils.parseLong(map.get("invitedPerson"));
 		
	
		invitRecord.invitedCoupon = Utils.parseLong(map.get("invitedCoupon"));
 		
	
		invitRecord.invitedDiscount = Utils.parseDouble(map.get("invitedDiscount"));
 		
	
		invitRecord.recom = Utils.parseLong(map.get("recom"));
 		
	
		invitRecord.recomCoupon = Utils.parseLong(map.get("recomCoupon"));
 		
	
		invitRecord.recomDiscount = Utils.parseDouble(map.get("recomDiscount"));
 		
	
		invitRecord.invitrType = Utils.parseShort(map.get("invitrType"));
 		
	
		invitRecord.updateTime = Utils.parseDate(map.get("updateTime"));
 		
	
		invitRecord.addTime = Utils.parseDate(map.get("addTime"));
 		
	
		invitRecord.status = Utils.parseShort(map.get("status"));
 		
	
		return invitRecord;
	}
	
	
	/**字段设置标记队列**/
	private Map<String,Boolean> seted=new HashMap();
	public Boolean getSeted(String key){
		return seted.get(key);
	}
	public void setSeted(String key){
		seted.put(key,true);
	}
	/**同步未set的字段**/
	public void mergeSet(InvitRecord old){
		Field[] fields = this.getClass().getDeclaredFields();
		try {
			for(Field field:fields){
				String key = field.getName();
				if(seted.get(key)==null && field.getAnnotation(column.class)!=null){
					field.setAccessible(true);
					field.set(this, field.get(old));					
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
		
	/**自定义变量存储**/
	private Map values=new HashMap();
	public Map getValues(){
		return values;
	}
	public void setValues(String name,Object value){
		values.put(name,value);
	}
	
	/**分表时的表名后缀**/
	private String suffix;
	public String getSuffix() {
		return suffix;
	}
	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}
	
	
	/**获取数据库名称**/
	public static String getDataBaseName(){
		return Utils.config("spring.datasource.distribute_sys.name");
	}
	
	
	public static String getIcon(){
		return "/images/icons/2008825642250778028.png";
	}
	public static String getIconfont(){
		return "icon-shuaxin2";
	}
	public static enum ACT{
		列表,添加,修改,详情
	};
	public static String getUrl(ACT act,InvitRecord.M params){
		if(params==null)params=new InvitRecord.M(0);
		params.remove("joins");
		params.remove("definexs");
		params.remove("distinct");
		String strUrl = "/admin/users/invitrecord.edit.html?";
		if(params.get("id")!=null){
			strUrl+="&id="+Utils.encode(""+params.get("id"),Utils.UTF8);
		}
		if(act==ACT.列表){
			strUrl = "/admin/users/invitrecord.html?1=1";
		
		}else if(act==ACT.添加){
			strUrl+="&edittype=insert";
		
		
		}else if(act==ACT.修改){
			strUrl+="&edittype=update";
		
		}else if(act==ACT.详情){
			strUrl+="&edittype=detail";
		
		}		
		if(params!=null){
			for(Object key:params.keySet()){
				strUrl+="&"+key+"="+Utils.encode(""+params.get(key),Utils.UTF8)+"";
			}
		}
		return strUrl;
	}
	public String getDetailUrl(){
		return this.getUrl(ACT.详情, where.id(this.getId()));
	}
	
	/**
	* 转跳到当前地址
	**/
	public static Protocol redirect(InvitRecord.ACT act,InvitRecord.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_REDIRECT");
		protocol.set("url",InvitRecord.getUrl(act, params));
		return protocol;
	}
	/**
	* 打开一个新的tab页面
	**/
	public static Protocol href(InvitRecord.ACT act,InvitRecord.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_HREF");
		protocol.set("url",InvitRecord.getUrl(act, params));
		protocol.set("title",act.name());
		return protocol;
	}
	/**
	* 显示一个消息框，并且关闭当前的对话框
	**/
	public static Protocol message(String message){
		Protocol protocol = Protocol.create(true,null,"ACT_MESSAGE");
		protocol.set("message",message);
		return protocol;
	}
	
	
	static com.distribute.framework.dao.IInvitRecordDao getInvitRecordDao(){
		return Utils.getBean("invitRecordDao");
	};
	
}